/* This is a panel used for the main menu
 * 
 */

package gui;

import gui.battle.ShipBattlePanel;
import gui.utilities.MyButton;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MainMenu extends JPanel{

	JPanel newGame; //the panel used to create the new game "button"
	JPanel load; //the panel used to create the load "button"
	JPanel settings; //the panel used for the settings "button"
	JPanel logo; //the panel that contains the game logo
	JPanel buttonPanel; //the panel that will hold the main buttons
	public MainMenu(){
		
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.setBackground(Color.PINK);
		logo = new JPanel();
		logo.setMaximumSize(new Dimension(800, 200));		
		logo.add(new JLabel(new ImageIcon("images\\title.gif")));
		logo.setOpaque(false);
		
		
		this.add(logo);
		
		//creates the main panel
		buttonPanel = new JPanel();
		buttonPanel .setMaximumSize(new Dimension(640, 450));
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
		buttonPanel.setOpaque(false);
		
		//creates the "buttons" on the main menu
		newGame = new JPanel();
		newGame.setMaximumSize(new Dimension(640, 50));
		newGame.setBackground(Color.BLUE);
		newGame.add(new JLabel("New Game"));
		newGame.addMouseListener(new MouseAdapter(){
			
			public void mouseEntered(MouseEvent e){
				
				newGame.setBackground(Color.GREEN);
			}//mouseEntered
			
			public void mouseExited(MouseEvent e){
				
				newGame.setBackground(Color.BLUE);
			}//mouseExited
			
			
			public void mouseClicked(MouseEvent e){
				
				newGame();
			}//mouseClicked
		});
		
		buttonPanel.add(newGame);
		
		load = new JPanel();
		load.setMaximumSize(new Dimension(640, 50));
		load.setBackground(Color.BLUE);
		load.add(new JLabel("Load"));
		load.addMouseListener(new MouseAdapter(){
			
			public void mouseEntered(MouseEvent e){
				
				load.setBackground(Color.GREEN);
			}//mouseEntered
			
			public void mouseExited(MouseEvent e){
				
				load.setBackground(Color.BLUE);
			}//mouseExited
			
			
			public void mouseClicked(MouseEvent e){
				
				System.out.println("Clicked Load");
			}//mouseClicked
		});
		
		buttonPanel.add(load);
		
		MyButton test = new MyButton("images\\regular.gif", "images\\hover.gif", 640, 50);
		
		test.setMaximumSize(new Dimension(640, 50));
		
		test.addMouseListener(new MouseAdapter(){
			
			//runs the new game method
			public void mouseClicked(MouseEvent e){
				
				newGame();
			}//mouseClicked
		});
		buttonPanel.add(test);
		
		settings = new JPanel();
		settings.setMaximumSize(new Dimension(640, 50));
		settings.setBackground(Color.BLUE);
		settings.add(new JLabel("Settings"));
		settings.addMouseListener(new MouseAdapter(){
			
			public void mouseEntered(MouseEvent e){
				
				settings.setBackground(Color.GREEN);
			}//mouseEntered
			
			public void mouseExited(MouseEvent e){
				
				settings.setBackground(Color.BLUE);
			}//mouseExited
			
			
			public void mouseClicked(MouseEvent e){
				
				System.out.println("Clicked Settings");
			}//mouseClicked
		});
		
		buttonPanel.add(settings);
		this.add(buttonPanel);
		
	}//default constructor
	
	
	//when the player selects the new game button
	private void newGame(){
		
		JPanel newGame = new JPanel(); //the new game panel
		JPanel playNameL = new JPanel(); //the label for the player name 
		JTextField playNameTF = new JTextField(15); // the text field that will hold the player name
		JPanel playName = new JPanel(); //the panel that holds both the player name "label" and text field
		
		playNameL.add(new JLabel("Player Name"));
		
		playName.setOpaque(false);
		playName.setLayout(new BoxLayout(playName, BoxLayout.X_AXIS));
		playName.add(playNameL);
		playName.add(playNameTF);
		
		newGame.setOpaque(false);
		newGame.add(playName);
		
		newGame.setMaximumSize(new Dimension(640, 450));
	
		this.remove(buttonPanel);
		this.add(newGame);
		this.revalidate();
	}//newGame
	
}//Main Menu
